import axios from 'axios'
import { promises } from 'fs';
axios.defaults.baseURL = 'http://lovegf.cn:8899';

export  const  getLunbotu=()=>{
    return axios.get("/api/getlunbo");
}
export const getNewsList=()=>{
    // 获取新闻列表
  return  axios.get("/api/getnewslist");
}

export const getNewsInf=(id)=>{
  return  axios.get("api/getnew/" + id);
}


//获取新闻页面获取评论
export const getComment=(params) =>{
  return axios.get(`api/getcomments/${params.id}?pageindex=${params.pageindex}`)
}

//提交新闻列表评论
export const postcomment=(paramst) =>{
  return axios.post("api/postcomment/"+paramst.id,{content:paramst.content}) 
}

//photo页面列表
export const getcate=() =>{
  return axios.get(`api/getimgcategory/`)
}

export const getImg=(params)=>{
  return  axios.get(`api/getimages/${params}`);
}
//图片详情页面
export const getImgInfo=(params) =>{
  return axios.get(`api/getimageInfo/${params}`)
}

// 详情缩略图
export const getThum=(params)=>{
  return axios.get(`api/getthumimages/${params}`)
}
//图片列表 
export const getGood=(params)=>{
  return axios.get(`api/getgoods?${params.pageindex}`)
}
//商品信息

export const getGoodsInfo=(params)=>{
  return axios.get(`api/goods/getinfo/${params}`)
}
export const goodsDesc=(params)=>{
  return axios.get(`api/goods/getdesc/${params}`)
}

//登录拦截部分
axios.interceptors.request.use(function(config){
  console.log(config);
  var mytoken = localStorage.getItem('mytoken');
  config.headers["Authorization"]=mytoken;

  //返回config;
  return config;
},
function(error){
  return Promise.reject(error);
});

export const login=(params)=>{
  return axios.post("http://www.lovegf.cn:8888/api/private/v1/login",params)
}
//发送请求
export const shopcarlist = (params)=>{
  return axios.get(`api/goods/getshopcarlist/${params}`)
}

// export const goComment=(params)=>{
//   return axios.get(`api/goods/getinfo/${params}`)
// }
// export const getGoodsInfo=(params)=>{
//   return axios.get(`api/goods/getinfo/${params}`)
// }